package com.sx.manage.controller.consumer.person;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sx.common.util.NumberUtil;
import com.sx.manage.controller.base.MBaseController;
import com.sx.manage.service.consumer.referee.RefereeWebServiceImpl;
import com.sx.manage.servlet.ViewAndModel;
import com.sx.model.manage.mybatis.form.consumer.feedback.MRefereeViewForm;
import com.sx.model.manage.mybatis.vo.consumer.feedback.MRefereeViewVO;
import com.sx.model.manage.mybatis.vo.result.ResultBooleanVO;
import com.sx.model.manage.mybatis.vo.result.ResultListVO;

/**
 * 推荐功能 controller
 * 
 * @author Administrator
 *
 */
@Controller
@RequestMapping("/referee")
public class MRefereeController extends MBaseController {
	private Logger log = LoggerFactory.getLogger(this.getClass());

	@Resource(name = "refereeWebServiceImpl")
	private RefereeWebServiceImpl refereeWebServiceImpl;

	/**
	 * 跳转到 列表界面
	 */
	@RequestMapping(value = "individualConsumer")
	public ViewAndModel consumerview() {
		log.debug("推荐发钱界面跳转");
		ViewAndModel model = new ViewAndModel(request, cache);
		model.setViewName("consumer/referee/refereeConsumer");
		return model;
	}

	/** 获取用户分页信息 */
	@RequestMapping(value = "page")
	@ResponseBody
	public ResultListVO<MRefereeViewVO> page(MRefereeViewForm form) {
		log.debug(" 推荐发钱界面跳转数据查询form={}", form);
		return refereeWebServiceImpl.queryRefereeConsumer(form);
	}

	/** 推荐人领取奖励 */
	@RequestMapping(value = "receive")
	@ResponseBody
	public ResultBooleanVO receive(MRefereeViewForm form) {
		log.debug("推荐人领取奖励 consumer_id={}", form.getBind_consumer_id());
		return refereeWebServiceImpl.receive(form.getBind_consumer_id());

	}

	/** 推荐人领取奖励 */
	@RequestMapping(value = "receive/batch")
	@ResponseBody
	public ResultBooleanVO receiveBatch(Long[] bind_consumer_ids) {
		log.debug("推荐人领取奖励 bind_consumer_ids={}", null != bind_consumer_ids ? NumberUtil.arrayToStr(bind_consumer_ids) : null);
		return refereeWebServiceImpl.receiveBatch(bind_consumer_ids);
	}
}
